import * as fileAPI from "../api/fileAPI";
import Message from "element-ui/packages/message/src/main";

const global = {
    serverAddress: "http://101.200.57.150:8001",
    noticeConfig: {
        title: "提示",
        duration: 0,
        showClose: false
    },
    noticeList: [],
    uploadFile: function (Id, fileType, callback) {
        console.log(Id)
        let file = document.createElement("input");
        file.setAttribute("type", "file");
        if (fileType) {
            file.setAttribute("accept", fileType);
        }
        let formData = new FormData();
        file.onchange = function () {
            formData.append("file", file.files[0]);
            callback({id: Id, file: formData});
        };
        file.click();
        file.remove();
    },
    uploadFile2: function (ids, fileType, callback) {
        let file = document.createElement("input");
        file.setAttribute("type", "file");
        if (fileType) {
            file.setAttribute("accept", fileType);
        }
        file.onchange = function () {
            let formData = new FormData();
            formData.append("file", file.files[0]);
            callback({graphId: ids[0], nodeId: ids[1], file: formData});
        };
        file.click();
        file.remove();

    }
};

export default global;